package com.example.config;

import com.example.Interceptor.LoginCheckInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Resource
    private LoginCheckInterceptor loginCheckInterceptor;


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        选择拦截器 并告诉拦截的路径 /** 是全部
        registry.addInterceptor(loginCheckInterceptor)
                .addPathPatterns("/**")//拦截的资源
                .excludePathPatterns("/login"); //不拦截的资源
    }
}
